package com.example.demo.service;

import com.example.demo.dao.UserMapper;
import com.example.demo.po.User;
import com.example.demo.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("UserService")
public class UserService {
    @Autowired
    UserMapper userMapper;

    public User findByUsername(User user) {
        return userMapper.findByUsername(user.getUsername());
    }

    public User findUserById(String userId) {
        return userMapper.findUserById(userId);
    }

    public int register(User user) {

        User nUser = new User();
        nUser.setUsername(user.getUsername());
        nUser.setPassword(MD5Util.md5(user.getPassword()));
        return userMapper.register(nUser);
    }
}